package com.yxw.live_vod_boot.controller;

import com.yxw.live_vod_boot.dto.fans.FansQueryDTO;
import com.yxw.live_vod_boot.service.FansService;
import com.yxw.live_vod_boot.vo.FansListVO;
import com.yxw.live_vod_boot.vo.FansNumberAndFollowNumberVO;
import com.yxw.yxnet_cd_center.common.dto.PageVO;
import com.yxw.yxnet_cd_center.common.helper.ResultHelper;
import com.yxw.yxnet_cd_center.common.utils.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author fangmaoxin
 * &#064;date  2023年11月21日
 */
@Slf4j
@RestController
@Api(value = "粉丝页接口", tags = "粉丝页")
@RequestMapping("/api/fans")
public class FansController {

    @Autowired
    private FansService fansService;

    /**
     * 店铺侧-展示自己的粉丝列表
     */
    @PostMapping("/getFansListForShop")
    @ApiOperation("店铺侧-展示自己的粉丝列表")
    public BaseResult<PageVO<FansListVO>> getFansListForShop(@RequestParam("shopId") Long shopId, @RequestBody @Validated FansQueryDTO dto) {
        PageVO<FansListVO> list = fansService.getFansListByShopId(shopId, dto);
        return ResultHelper.fillWithSuccess(list);
    }

    /**
     * 店铺侧-查询自己的关注数量和粉丝数量
     */
    @PostMapping("/getFansNumberAndFollowNumberForShop")
    @ApiOperation("店铺侧-查询自己的关注数量和粉丝数量")
    public BaseResult<FansNumberAndFollowNumberVO> getFansNumberAndFollowNumberForShop(@RequestParam("shopId") Long shopId) {
        FansNumberAndFollowNumberVO result = fansService.getFansNumberAndFollowNumberForShop(shopId);
        return BaseResult.doSuccess(result, "操作成功！");
    }

    /**
     * 用户侧-展示自己的粉丝列表
     */
    @PostMapping("/getFansListForUser")
    @ApiOperation("用户侧-展示自己的粉丝列表")
    public BaseResult<PageVO<FansListVO>> getFansListForUser(@RequestParam("userId") Long userId, @RequestBody @Validated FansQueryDTO dto) {
        PageVO<FansListVO> list = fansService.getFansListForUser(userId, dto);
        return ResultHelper.fillWithSuccess(list);
    }

    /**
     * 用户侧-查询自己的关注数量和粉丝数量
     */
    @PostMapping("/getFansNumberAndFollowNumberForUser")
    @ApiOperation("用户侧-查询自己的关注数量和粉丝数量")
    public BaseResult<FansNumberAndFollowNumberVO> getFansNumberAndFollowNumberForUser(@RequestParam("userId") Long userId) {
        FansNumberAndFollowNumberVO result = fansService.getFansNumberAndFollowNumberForUser(userId);
        return BaseResult.doSuccess(result, "操作成功！");
    }
}
